package com.xyebank.ledger.service.nx.dataprovider.pay;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xyebank.ledger.service.common.DataProvider;
import com.xyebank.ledger.vo.deal.LNxCashPaymentInfoVo;

@Component
public class NxPayDataProvider implements DataProvider<LNxCashPaymentInfoVo> {

    @Autowired
    private SNxCashPaymentMapper sNxCashPaymentMapper;

    @Override
    public List<LNxCashPaymentInfoVo> get(Integer fromIdx, Integer tarNum) {
        List<SNxCashPayment> result = sNxCashPaymentMapper.selectByPaging(fromIdx, tarNum);
        List<LNxCashPaymentInfoVo> list = new ArrayList<LNxCashPaymentInfoVo>();
        for (int i = 0; i < result.size(); i++) {
            LNxCashPaymentInfoVo vo = new LNxCashPaymentInfoVo();
            BeanUtils.copyProperties(result.get(i), vo);
            list.add(vo);
        }
        return list;
    }


    @Override
    public List<LNxCashPaymentInfoVo> get(Date dateStart, Date dateEnd, Integer fromIdx, Integer tarNum) {
        List<SNxCashPayment> result = sNxCashPaymentMapper.selectByPeriod(dateStart, dateEnd, fromIdx, tarNum);
        List<LNxCashPaymentInfoVo> list = new ArrayList<LNxCashPaymentInfoVo>();
        for (int i = 0; i < result.size(); i++) {
            LNxCashPaymentInfoVo vo = new LNxCashPaymentInfoVo();
            BeanUtils.copyProperties(result.get(i), vo);
            list.add(vo);
        }
        return list;
    }

    @Override
    public Integer count(Date timeStart, Date timeEnd) {
        Integer count = sNxCashPaymentMapper.selectPeriodCount(timeStart, timeEnd);
        return count;
    }
}
